home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8128 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  56 lines

  1. Path: ccnet.com!not-for-mail
  2. From: jantypas@ccnet.com (John Antypas)
  3. Newsgroups: comp.lang.c++
  4. Subject: Call order of constructors
  5. Date: 14 Feb 1996 16:34:31 -0800
  6. Organization: CCnet Communications
  7. Message-ID: <4ftv2n$kts@ccnet3.ccnet.com>
  8. NNTP-Posting-Host: ccnet3
  9.  
  10. Hello C++ wizards...
  11.  
  12. I'm trying to create a library access some private netowrk resources. 
  13. I thought I'd try something like this:
  14.  
  15. class TRANSPORT {
  16.     ... magic stuff...
  17. public:
  18.     TRANSPORT(char *name)    // Called to activate and bind transport(name)
  19.     ~TRANSPORT()        // Called when we're done with transport(name)
  20.  
  21. }
  22.  
  23. class SESSION(
  24.     TRANSPORT transport&;
  25.     ....
  26.     SESSION(char *transport_name, 
  27.         char *transport_address);
  28.     ~SESSION();
  29.     ....
  30. }
  31.  
  32. I was hoping that main code such as :
  33.  
  34.     SESSION    my_session("iee488", "unit-4B");
  35.  
  36. would create a session on the IEEE488 controller, to unit Unit-4B, specifically,    - open a trasnport to the IEEE-488 system by calling the IEEE488
  37.       constructor
  38.     - open a session by calling the session constructor and have it
  39.       finish the job.
  40.  
  41. The destructor sequence runs in the exact reverse.
  42.  
  43. First off, the compiler complains about the TRANSPORT constructors, second,
  44. I find myself asking what to do if a constructor or destructor fails?
  45. How do I catch the error condition to notify outer levels of the program?
  46.  
  47. Help as always is appreciated.
  48.  
  49. John Antypas    jantypas@soft21.s21.com
  50.  
  51. -- 
  52. John Antypas@21st Century Softwware (jantypas@soft21.s21.com)
  53.  
  54. "God is too busy to create chaos and disorder in this world, he can't be
  55.  everywhere at once all of the time,  That's why he made two year olds"
  56.